package org.shunfeng.dao.impl;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.shunfeng.dao.CompanyDao;
import org.shunfeng.pojo.Company;
import org.shunfeng.utils.DruidUtils;

import java.sql.SQLException;
import java.util.List;

public class CompanyDaoImpl implements CompanyDao {
    private QueryRunner qr = new QueryRunner(DruidUtils.getDataSource());
    @Override
    public List<Company> queryAllCompany() throws SQLException {
        String sql = "select id as id, company_name as companyName from sys_company";
        return qr.query(sql, new BeanListHandler<Company>(Company.class));
    }
}
